
package quartz;

import java.util.Date;
import java.util.Timer;

/**
 * 測試排程, 使用 MyTask instance
 * <br>
 * Copyright: Copyright (c) 2001-2007<br>
 * Company: 一零四資訊科技股份有限公司
 * @author Eric.Kao(eric.kao@104.com.tw)
 * @version 1.0
 */
public class TestQuartz
{
	public TestQuartz() throws InterruptedException
	{
		Timer timer = new Timer();
		
		//每隔 3 秒, 執行排程一次 
		timer.schedule( new MyTask(), getFirstDate(), 3 * 1000 );
	}

	public static void main( String[] args )
	{
		try
		{
			new TestQuartz();
		}
		catch( InterruptedException ex )
		{
		}
	}

	/**
	 * 取得排程第一次執行的時間, 並 sleep 5秒
	 * @return
	 * @throws InterruptedException
	 */
	private Date getFirstDate() throws InterruptedException
	{
		Date date = new Date();

		System.out.println( "FirstDate:" + date );

		Thread.sleep( 5 * 1000 );

		return date;
	}
}
